/* Written and copyright 2001-2003 Benjamin Kohl.
 * Distributed under the GNU General Public License; see the README file.
 * This code comes with NO WARRANTY.
 */

//import java.awt.Dimension;
//import java.awt.Toolkit;
//import javax.swing.UIManager;

//import Jhttpp2MainFrame;
package jhttpp2;

import java.util.HashMap;

import p2p.P2PautoRemoveFriend;
import p2p.P2pClientThread;
import p2p.P2pPing;

/**
 * Title:        jHTTPp2: Java HTTP Filter Proxy
 * Description: starts thwe Swing GUI or the console-mode only proxy
 * Copyright:    Copyright (c) 2001-2003
 *
 * @author Benjamin Kohl
 */

public class Jhttpp2Launcher {

	static Jhttpp2Server server;
	static P2pClientThread p2p;
	static P2pPing p2pping;
	static P2PautoRemoveFriend p2pautoremove;

	public static void main ( String[] args ) {
		//create new server to service connect	
		p2pping = new P2pPing();
		p2pping.start();
		
		server = new Jhttpp2Server(true);
		p2p = new P2pClientThread(P2pClientThread.ECHOPORT, P2pClientThread.NUM_THREADS);
		
		//create locked hashmap to flag locked writing url
		Jhttpp2Read.lockUrl = new HashMap< String, Integer >();
		Jhttpp2Read.lockUrl.clear();
		
		p2pautoremove = new P2PautoRemoveFriend();
	   	p2pautoremove.start();
	   	System.out.println("Start p2p remove bad Friend");
	   	
    	if (server.error) {
    		System.out.println("Error: " + server.error_msg);
		}
    	else {
//    		server.debug = true;
    		// create thread sever
    		
    		new Thread(server).start();
    		new Thread(p2p).start();
    	   	System.out.println("Running on port " + server.port);
    	}
	}
}